package com.nameless.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.nameless.dao.CarCommentDao;
import com.nameless.dao.MaintainShopDao;
import com.nameless.entity.Brand;
import com.nameless.entity.CarComment;
import com.nameless.entity.MaintainShop;
import com.nameless.service.MaintainShopService;
import com.nameless.vo.BrandVo;
import com.nameless.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author keluoyisi
 * @program: car-parent
 * @description:
 * @date 2023-02-28 14:16:27
 */
@Service
@SuppressWarnings("all")
public class MaintainShopServiceImpl extends ServiceImpl<MaintainShopDao, MaintainShop> implements MaintainShopService {
    @Autowired
    private MaintainShopDao maintainShopDao;
    @Override
    public Result queryAllByParam(BrandVo brandVo) {
        PageHelper.startPage(brandVo.getPageNum(),brandVo.getPageSize());
        QueryWrapper<MaintainShop> wrapper =null;
        if (brandVo.getName()!=null){
            wrapper = new QueryWrapper<>();
            wrapper.like("name",brandVo.getName());

        }
        List<MaintainShop> brands = maintainShopDao.selectList(wrapper);
        PageInfo<MaintainShop> info = new PageInfo<>(brands);
        return new Result(200,"成功",info);
    }

    @Override
    public Result updateMaintainShop(MaintainShop maintainShop) {
        int i = maintainShopDao.updateById(maintainShop);
        return new Result(200,"成功");
    }

    @Override
    public Result insertMaintainShop(MaintainShop maintainShop) {
        int insert = maintainShopDao.insert(maintainShop);
        return new Result(200,"成功");
    }

    @Override
    public Result deleteMaintainShopById(Integer id) {
        int i = maintainShopDao.deleteById(id);
        return new Result(200,"成功");
    }

    @Override
    public Result queryAll() {
        List<MaintainShop> maintainShops = maintainShopDao.selectList(null);
        return new Result(200,"成功",maintainShops);
    }
}
